import Mock from 'mockjs';
var data = [{
    "id": 1,
    "name": "周国鹏",
    "gaoname": "马云",
    "username": "admin",
    "password": "123456"
}, {
    "id": 2,
    "name": "郭昊源",
    "gaoname": "丁磊",
    "username": "admin",
    "password": "456789"
}]
Mock.mock('/list', 'post', function (options) {
    var params = JSON.parse(options.body);
    var { username, password } = params;
    var obj = data.find(item => {
        return item.username === username && item.password === password;
    })
    if (obj) {
        return {code:200,msg:"登录成功",token:Mock.Random.word(),obj:obj}
    }else{
        return {code:400,msg:"登录失败"}
    }
})
Mock.mock('/getlist', 'post', function (options) {
    var params = JSON.parse(options.body);
    var {id} = params;
    var objs=data.find(item=>{
        return item.id===id
    })
    return {
        list:objs
    }
})
